#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time    : 2021/3/9 23:41
# @Author  : cjw

# 数据类(构造常用数据类型、UUID、文本、词组、文件链接、文件路径)
# 安全类(构造操作系统信息、HASH加密、密码)
# 信息类(构造个人信息数据和表单信息数据：姓名、地址、电话、工作、证件号、银行卡号、公司、邮箱、生日)
# 网络类(构造IP MAC HTTP的客户端类型和文件类型，反反爬)

from faker import Factory

fake = Factory.create('zh_CN')


def random_python_data():
    """python常用数据类型"""
    return fake.pystr(), fake.pyint(), fake.pybool(), \
           fake.pyfloat(), fake.pytuple(nb_elements=2), fake.pylist(nb_elements=2), \
           fake.pydict(nb_elements=2)


def random_num(min_value=1, max_value=9999, step=1):
    return fake.pyint(min_value, max_value, step)


def random_uuid():
    return fake.uuid4()


def random_text():
    return fake.text()


def random_word(is_words: bool = False, nb=3, ext_word_list=None, unique=False):
    if is_words:
        return fake.words(nb, ext_word_list, unique)
    else:
        return fake.word(ext_word_list)


def random_image_url():
    return fake.image_url()


def random_file_path():
    return fake.file_path(extension='mp4')


def random_os_info(os_type: str = 'win'):
    if os_type == 'win':
        return fake.windows_platform_token() + '  ' + fake.linux_processor()
    if os_type == 'linux':
        return fake.linux_processor()
    if os_type == 'mac':
        return fake.mac_platform_token()
    if os_type == 'ios':
        return fake.ios_platform_token()
    if os_type == 'android':
        return fake.android_platform_token()


def random_hash(raw_output: bool = False):
    """

    :param raw_output: 是否以二进制返回
    :return:
    """
    return {'md5': fake.md5(raw_output), 'sha1': fake.sha1(raw_output), 'sha256': fake.sha256(raw_output)}


def random_password(length=10, special_chars=True, digits=True, upper_case=True, lower_case=True):
    return fake.password(length=length, special_chars=special_chars, digits=digits, upper_case=upper_case,
                         lower_case=lower_case)


def random_name():
    return fake.name()


def random_address():
    """地址的省市区非正确"""
    return fake.address()


def random_phone_number():
    return fake.phone_number()


def random_job():
    return fake.job()


def random_ssn(min_age=18, max_age=90, gender=None):
    """
    身份证号: 可以指定生成年龄段
    :param min_age: 最小年龄
    :param max_age: 最大年龄
    :param gender: 性别，男性：M，女性：F
    :return:
    """
    return fake.ssn(min_age, max_age, gender)


def random_credit_card(card_full: bool = False):
    """
    获取银行卡信息
    :param card_full: 是否获取完整的信息
    :return:
    """
    if not card_full:
        return fake.credit_card_number()
    else:
        return fake.credit_card_full()


def random_company():
    return fake.company()


def random_email(domain=None):
    """
    :param domain: 邮箱域名：例如’qq.com‘
    :return:
    """
    return fake.email(domain)


def random_birth(minimum_age=18, maximum_age=45):
    """生日"""
    return fake.date_of_birth(minimum_age=minimum_age, maximum_age=maximum_age)


def random_profile():
    """一次性生成用户信息"""
    return fake.profile()


def random_ipv4(private=False, public=False):
    if private:
        return fake.ipv4_private()
    if public:
        return fake.ipv4_public()
    return fake.ipv4()


def random_ipv6():
    return fake.ipv6()


def random_mac_address():
    return fake.mac_address()


def random_user_agent():
    return fake.user_agent()


def random_mime_type(category: str = 'application'):
    return fake.mime_type(category)


if __name__ == '__main__':
    # print(type_str := random_uuid(), type(type_str))
    # print(random_ssn(30, 40))
    print(random_python_data())
